#ifndef PROCESS_CC
#define PROCESS_CC

#include <iostream>
#include "Process.h"

using namespace std;

Process::Process(){
	PID = -1;
	arrival = -1;
	burst = -1;
	priority = -1.0;
	startTime =-1;
	endTime=-1;
	userProcess = -1;
	remainingTime=-1;
	runTime =0;
	waitTime =0;
	queueNumber=6;
	runTimeinQueue = 0;
	age = 0;
}

Process::Process(int pID, int thearrival, int burstnum, double prior, int userProc, int running, int waiting){
	PID = pID;
	arrival = thearrival;
	burst = burstnum;
	priority = prior;
	startTime =-1;
	endTime=-1;
	userProcess = userProc;
	remainingTime = burst;
	runTime = running;
	waitTime = waiting;
	queueNumber =6;
	runTimeinQueue = 0;
	age =0;
	
}
Process::~Process(){

}

void Process::operator=(const Process &aProcess){
	PID = aProcess.PID;
	arrival = aProcess.arrival;
	burst = aProcess.burst;
	priority = aProcess.priority;
	waitTime = aProcess.waitTime;
	startTime= aProcess.startTime;
	endTime = aProcess.endTime;
	userProcess = aProcess.userProcess;
	remainingTime = aProcess.remainingTime;
	queueNumber = aProcess.queueNumber;
	runTime = aProcess.runTime;
	waitTime = aProcess.waitTime;
	runTimeinQueue = aProcess.runTimeinQueue;
	age= aProcess.age;
	
}
bool Process::operator<(const Process &aProcess) const{
	bool result = true;
	if (userProcess==1){
		//HRN


		if (priority>aProcess.priority){

			//cout<<*this <<" >"<< aProcess<<endl;
			result = false;
		}else if (priority==aProcess.priority){
			if (arrival<aProcess.arrival){
			//cout<<*this <<" > "<< aProcess<<endl;
				result =false;
			}
			//cout<<*this <<" < "<< aProcess<<endl;
		}
		else {
		//	cout<<*this <<" < "<< aProcess<<endl;
		}

	}else if (userProcess==2){
		if (arrival< aProcess.arrival){
			result = false;
		}

	}else if(userProcess==3){
	
	}
	//cout<<endl;
	return result;

}

void Process::setQueueNumber(int num){
      queueNumber = num;

}
int Process::getPID(){return PID;}
int Process::getArrival(){return arrival;}
int Process::getBurst(){return burst;}
double Process::getPriority(){return priority;}
void Process::setEndTime(int time){

	endTime = time;
}
void Process::setHRNPriority(){
	priority = ((double)waitTime+(double)burst)/(double)burst;
//	cout<<"Changing priority of PID "<<PID<<"to: "<<waitTime<<"+"<<burst<<"/"<<burst<<"="<<priority<<endl;
	
}

bool Process::isLessThan(const Process& aProcess)const{
	bool result = true;
	if (userProcess==1){
		//HRN


		if (priority>aProcess.priority){

			//cout<<*this <<" >"<< aProcess<<endl;
			result = false;
		}else if (priority==aProcess.priority){
			if (arrival<aProcess.arrival){
			//cout<<*this <<" > "<< aProcess<<endl;
				result =false;
			}
			//cout<<*this <<" < "<< aProcess<<endl;
		}
		else {
		//	cout<<*this <<" < "<< aProcess<<endl;
		}

	}else if (userProcess==2){
		if (arrival< aProcess.arrival){
			result = false;
		}

	}else if(userProcess==3){
	
	}
	//cout<<endl;
	return result;
}
void Process::setUserProcess(int num){
	userProcess = num;
}

void Process::display(ostream& os) const{
	os << "Process ID: " << PID << " Arrival: " << arrival << " Burst: " << burst << " Priority: " << (double)priority << " Remaining Time: "<< remainingTime<< " Queue Number; "<<queueNumber<<" Run Time in Queue: "<< runTimeinQueue<<" Age: "<<age<<endl;
}


#endif



